package com.oasistudio.ads.expert;

import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.LinearLayout.LayoutParams;

public class OthersStatistics extends Activity {

	public void onCreate(Bundle bundle) {
		super.onCreate(bundle);
		setContentView(R.layout.other_statistics);
		 addImage("无线网络广告市场规模-iResearch-2011",
				 R.drawable.image_00_wireless_ad_scale,
				 "http://www.iresearch.com.cn/Report/1578.html");
		addImage("互联网网民数-CNNIC-2011-06", R.drawable.image_01_cnnic_netizen,
		 "http://www.luoxianqing.com/emarketing/focus/20110725131918_472.shtml");
		 addImage("非网民为何不上网-CNNIC-2011-06", R.drawable.image_02_cnnic_netizen,
		 "http://www.luoxianqing.com/emarketing/focus/20110725131918_472.shtml");
		 addImage("无线网民数-iResearch-2011",
				 R.drawable.image_03_iresearch_wireless_netizen,
				 "http://www.iresearch.com.cn/Report/1578.html");
		 addImage("无线网民教育程度-iResearch-2011",
				 R.drawable.image_04_iresearch_users_education,
				 "http://www.iresearch.com.cn/Report/1578.html");
		 addImage("无线网民上网干什么-iResearch-2011",
				 R.drawable.image_05_iresearch_what_users_do,
				 "http://www.iresearch.com.cn/Report/1578.html");
		 addImage("无线网民App下载-iResearch-2011",
				 R.drawable.image_06_iresearch_app_download,
				 "http://www.iresearch.com.cn/Report/1578.html");
		 addImage("无线网民月均App下载数目分布-iResearch-2011",
				 R.drawable.image_07_how_many_users_download,
				 "http://www.iresearch.com.cn/Report/1578.html");
		 addImage("移动互联网细分行业构成2010-iResearch-2011",
				 R.drawable.image_08_iresearch_trade_distribution,
				 "http://www.iresearch.com.cn/Report/1578.html");
		 addImage("移动互联网细分行业构成变化趋势-iResearch-2011",
				 R.drawable.image_09_iresearch_trade_percentage,
				 "http://www.iresearch.com.cn/Report/1578.html");
		 addImage("移动互联网市场规模-iResearch-2011",
				 R.drawable.image_10_wireless_scale,
				 "http://www.iresearch.com.cn/Report/1578.html");
		 addImage("手机购物占比-iResearch-2011",
				 R.drawable.image_11_online_shopping_wireless,
				 "http://www.iresearch.com.cn/Report/1578.html");
		 addImage("手机购物网站Top10-iResearch-2011",
				 R.drawable.image_12_where_users_shopping,
				 "http://www.iresearch.com.cn/Report/1578.html");
		 
		 //"http://www.iresearch.com.cn/Report/1578.html"
	}

	private void addImage(String title, int id, final String url){
		LinearLayout statContainer = (LinearLayout) findViewById(R.id.other_statistics);
		statContainer.addView(this.createTitle(title));
		Drawable drawable = getResources().getDrawable(id);
		ImageView imageView = new ImageView(this);
		imageView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
		imageView.setImageDrawable(drawable);
		statContainer.addView(imageView);
		imageView.setClickable(true);
		imageView.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
				startActivity(myIntent);
			}
		});
	}
	
	private TextView createTitle(String text) {
		TextView textView = new TextView(this);
		textView.setText(text);
		// textView.setId(5);
		textView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
		return textView;
	}
}